{$old_status}_to_{$new_status}
Action HookDescription
Fires when a post is transitioned from one status to another. The dynamic portions of the hook name, `$new_status` and `$old_status`, refer to the old and new post statuses, respectively. Possible hook names include: - `draft_to_publish` - `publish_to_trash` - `pending_to_draft`Hook Information
File Location |
wp-includes/post.php
View on GitHub
|
Hook Type | Action |
Line Number | 5758 |
Hook Parameters
Type | Name | Description |
---|---|---|
WP_Post
|
$post
|
Post object. |
Usage Examples
Basic Usage
<?php
// Hook into {$old_status}_to_{$new_status}
add_action('{$old_status}_to_{$new_status}', 'my_custom_function', 10, 1);
function my_custom_function($post) {
// Your custom code here
}
Source Code Context
wp-includes/post.php:5758
- How this hook is used in WordPress core
<?php
5753 *
5754 * @since 2.3.0
5755 *
5756 * @param WP_Post $post Post object.
5757 */
5758 do_action( "{$old_status}_to_{$new_status}", $post );
5759
5760 /**
5761 * Fires when a post is transitioned from one status to another.
5762 *
5763 * The dynamic portions of the hook name, `$new_status` and `$post->post_type`,
PHP Documentation
<?php
/**
* Fires when a post is transitioned from one status to another.
*
* The dynamic portions of the hook name, `$new_status` and `$old_status`,
* refer to the old and new post statuses, respectively.
*
* Possible hook names include:
*
* - `draft_to_publish`
* - `publish_to_trash`
* - `pending_to_draft`
*
* @since 2.3.0
*
* @param WP_Post $post Post object.
*/
Quick Info
- Hook Type: Action
- Parameters: 1
- File: wp-includes/post.php
Related Hooks
Related hooks will be displayed here in future updates.